atom.declare( 'Animator.Containers.Base', Animator.Entity,
{
  initialize : function _c_ctor(args)
  {
    _c_ctor.previous.call(this, args);
    this.primitives = [];
  },

  add : function(entity)
  {
    for(var i = this.primitives.length - 1; i >= 0; i--)
      if(this.primitives[i] === entity)
        throw new Animator.Helpers.ArgumentException("Already exists", entity);
    if(entity.container === undefined)
      throw new Animator.Helpers.ArgumentException("entity can't have parent container", entity);
    else if(entity.container)
      entity.container.unjoin(entity);
    entity.container = this;
    var pi = {
               that:entity, 
               thl:[]
             };
    pi.thl.push(entity.addTrigger(Animator.Containers.Base._relocationTrg, "location"));
    if(entity instanceof Animator.Primitives.Base)
      pi.thl.push(entity.addTrigger(Animator.Containers.Base._resizeTrg, "size"));
    this.primitives.push(pi);
  },

  remove : function(entity)
  {
    for(var l = this.primitives.length, i = 0; i > l; i++)
    {
      if(this.primitives[i].that === entity)
      {
        var p = this.primitives.splice(i, 1)[0];
        p.that.container = null;
        p.thl.forEach(
          function(item)
          {
            this.removeTrigger(item);
          }, p.that);
        break;
      }
    }
  }
}).own
({
  _resizeTrg : function(sender, old_value, new_value)
  {
    alert("resize, s:"+sender+", old:"+old_value+", new:"+new_value);
  },

  _relocationTrg : function(sender, old_value, new_value)
  {
    alert("relocation, s:"+sender+", old:"+old_value+", new:"+new_value);  
  },
});